<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <style>
      .el-input__inner{
      border: 0;
      font-size: 1rem;
      text-align: center;
    }.el-input__prefix{
      display: none;
    }
    </style>
</head>
<body style="background: #ffffff;">

  <div class="mui-content" style="margin-top:0px;">
    <div id="vm" class="x-examok" v-cloak>
      <!--  -->
      <div class="x-ico-month x-ico-month2">
        <el-date-picker v-model="cardsmonth" type="month" placeholder="选择日" @change="getmonth" format="yyyy 年 MM 月" value-format="yyyyMM" :editable="notkey"></el-date-picker>
    </div>
    <!--  -->
    <el-table :data="tabledata">
        <el-table-column label="学习岗位" width="" fixed>
            <template slot-scope="scope">
            {{scope.row.source_title}}
            </template>
        </el-table-column>
        <el-table-column label="学习内容" width="">
            <template slot-scope="scope">
            {{scope.row.title}}
            </template>
        </el-table-column>
        <el-table-column label="学习时间" width="">
            <template slot-scope="scope">
              {{scope.row.take_date1}}-{{scope.row.take_date2}}
            </template>
        </el-table-column>
        <el-table-column label="带训人" width="">
          <template slot-scope="scope">
            {{scope.row.take_username}}
          </template>
        </el-table-column>
        <el-table-column label="完成确认" width="130">
          <template slot-scope="scope">
            <el-button type="primary" v-if="scope.row.is_finish=='0'" @click="examok(scope.row.id,scope.row.title)" size="mini">点击确认</el-button>
            <div v-else>
                <div v-if="scope.row.is_finish==1">已完成</div>
                <div v-if="scope.row.is_finish==2">未完成</div>
            </div>
            </template>
        </el-table-column>
    </el-table>
    <!--  -->
    <el-dialog :title="'请对“'+scoretoasttitle + '”进行打分'" :visible.sync="dialogVisible" width="90%" center="true" close-on-click-modal="false" show-close="false">
      <div class="x-tra-nin">
        <el-input-number v-model="scoredata" @change="getscorenum" :min="1" :max="10" label="描述文字"></el-input-number>
        <div class="x-tra-desc"></div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="okgetscore">确 定</el-button>
      </span>
    </el-dialog>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
	<script>
apiready = function () {
  api.setRefreshHeaderInfo({
        loadingImg: 'widget://image/refresh.png',
        bgColor: '#ccc',
        textColor: '#fff',
        textDown: '下拉刷新...',
        textUp: '松开刷新...'
    }, function(ret, err) {
        setTimeout(function(){api.refreshHeaderLoadDone()},500)
        vm.gettrainadmin()
    });


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          cardsmonth:'',
          notkey:false,
          tabledata:[],
          taskratevalue:0,
          dialogVisible:false,
          scoretoasttitle:'',
          scoredata:0,
        }
      },
      created:function() {
        var that=this;
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var day = date.getDate();
        if(month<10){
          month = '' + 0 + month;
        }
        var toMonth = '' + year + month;
        that.cardsmonth = toMonth;
        this.gettrainadmin()


      },
      mounted:function(){
        var that=this;

      },
      methods: {
        getmonth:function(){
          this.gettrainadmin()
        },
        //自我评价
        getnumber:function(id,name,type){
          var that = this;
          that.dialogVisible = true;//显示弹窗
          that.scoretoasttitle = name;
          that.scoretoastid = id;

        },
        //获取打分分数
        getscorenum:function(val){
          var that = this;
          that.scoredata = val;
        },
        //自我评价提交
        okgetscore:function(){
          let that=this;
          that.dialogVisible = false;//显示弹窗
          api.ajax({
            url:baseurl+'api/task/setMyScore',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                id:that.scoretoastid,
                score:that.scoredata
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.gettrainadmin()


              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //完成考核确认
        examok:function(id,name){
          var that = this;
          api.actionSheet({
              title: '请确认“'+ name + '”是否完成',
              cancelTitle: '取消',
              buttons: ['已完成', '未完成']
          }, function(ret, err) {
              var index = ret.buttonIndex;
              console.log(index);// 1 2
              if(index=='1'){
                that.examgoajax(id,index)
              }else if(index=='2'){
                that.examgoajax(id,index)
              }

          });

        },
        //完成确认 提交
        examgoajax:function(id,index){
          let that=this;
          api.ajax({
            url:baseurl+'api/task/setFinish',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                id:id,
                type:index
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.gettrainadmin()


              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //列表0
        gettrainadmin:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/task/study',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.cardsmonth,
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              that.tabledata = ret.data.list;//0未操作 1完成 2未完成 
              
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
     
      }
    })
	}


	</script>
</body>
</html>
